package com.seguriapp.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.seguriapp.R;

public class GenericDialog extends Dialog {

	public static int WELCOME_DIALOG = 0;
	private static GenericDialog dialog;
	private static Context mContext;

	private GenericDialog(final Context context) {
		super(context);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		mContext = context;
		setContentView(R.layout.dialog_generic);
	}

	public static GenericDialog createDialog(final Context context,
			final int title, final int text, final int action) {
		dialog = new GenericDialog(context);
		final TextView dialogTitle = (TextView) dialog
				.findViewById(R.id.dialog_title);
		dialogTitle.setText(title);
		final TextView dialogText = (TextView) dialog
				.findViewById(R.id.dialog_text);
		dialogText.setText(text);
		setButtons(action);

		return dialog;
	}

	private static void setButtons(final int action) {
		final Button dialog_ok_btn = (Button) dialog
				.findViewById(R.id.dialog_btn);
		if (action == WELCOME_DIALOG) {
			dialog_ok_btn.setOnClickListener(new Button.OnClickListener() {
				public void onClick(final View view) {
					dialog.dismiss();
					UserInformationDialog.createDialog(mContext).show();
				}
			});
		}
	}

}
